<script setup lang="ts">
import {onMounted, ref} from "vue";
import TopView from "./components/TopView.vue"
import TouristNum from "./components/TouristNum.vue";
import SexRate from "./components/SexRate.vue";
import AgeRate from "./components/AgeRate.vue";
import Map from "./components/Map.vue";
import TouristLine from "./components/TouristLine.vue";
import HotArea from "@/views/Screen/components/HotArea.vue";
import YearNum from "@/views/Screen/components/YearNum.vue";
import Subscribe from "@/views/Screen/components/Subscribe.vue";
const screenRef = ref();
const getScale = (w = 1920, h = 1080) => {
  let ww = window.innerWidth / w;
  let wh = window.innerWidth / h;
  return ww < wh ? ww : wh;
}

onMounted(() => {
  screenRef.value.style.transform = `scale(${getScale()}) translate(-50%,-41%)`;
  // screenRef.value.style.transform = `scale(0.8) translate(0%,0%)`;
});
// 监听视口变化
window.onresize = () => {
  screenRef.value.style.transform = `scale(${getScale()}) translate(-50%, -41%)`;
}
</script>

<template>
  <div class="container">
    <div class="screen" ref="screenRef">
      <TopView/>
      <div class="bottom">
        <div class="left">
          <TouristNum/>
          <SexRate/>
          <AgeRate/>
        </div>
        <div class="middle">
          <Map/>
          <TouristLine/>
        </div>
        <div class="right">
          <HotArea/>
          <YearNum/>
          <Subscribe/>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.container {
  width: 100vw;
  height: 100vh;

  .screen {
    width: 1920px;
    height: 1080px;
    position: fixed;
    left: 50%;
    top: 50%;
    transform-origin: left top;

    .bottom {
      display: flex;
      .left {
        flex: 1;
        height: 1040px;
        background-color: #606266;
        display: flex;
        flex-direction: column;
      }

      .middle {
        flex: 2;
        display: flex;
        flex-direction: column;
      }

      .right {
        flex: 1;
        display: flex;
        flex-direction: column;
      }
    }
  }
}
</style>